#ifndef JPROJECT_H
#define JPROJECT_H

#include <QObject>
#include <QStringList>
#include <QStandardItemModel>
#include <QStandardItem>
#include <QDomDocument>
#include <QDomElement>

class JProject : public QObject
{
	Q_OBJECT

public:
	static JProject& Instance();

	QModelIndex selectionIndex();
	void updateIndex(QModelIndex index);
	QStandardItemModel* itemModel();
	QStandardItem* itemFromIndex(QModelIndex index);

public slots:

	QString Name();
	QString FileName();
	QString FilePath();

	bool Load(const QDomElement& element);
	void New(const QString& name, const QString& filePath);
	QDomElement Save(QDomDocument& document);

	bool isModified() {return m_bModified;}
	bool isEmpty() { if(m_Path.isEmpty()) return true; else return false; }

	void Add3DModel(const QString& filePath);
	void AddKinematics(const QString& filePath);

private slots:
	//void addNewModel();
	//void addNewKinematics();
	//void setName(const QString& newName) {m_Name = newName;}
	//void setModified(bool flag); {m_bModified = flag;}

private slots:
	//bool save();
	//void load(const QString& fileName);

signals:
	//void sendSave(QDomElement *);

private:
	JProject();
	JProject(const JProject &);
	~JProject();

	QDomElement saveToXML(QDomDocument& document);
	bool loadFromXML(const QDomElement& element);

	QString m_Name;
	QString m_Path;

	QDomElement m_RootItem;

	QStandardItemModel* m_pItemModel;
	QStandardItem* m_pProjectItem;
	QModelIndex m_Index;

	QStringList m_3DModelList;
	//QHash<QString,J3DModel*> m_ModelList;
	
	bool m_bModified;
};

#define Project JProject::Instance()

#endif // JPROJECT_H
